package czh.cocoa.foundation;

public class NSMutableString extends NSString {

	private StringBuilder mStringBuilder;
	
	public NSMutableString() {
		this("");
	}
	
	public NSMutableString(NSString str) {
		this(str.toString());
	}
	
	public NSMutableString(String str) {
		mStringBuilder = new StringBuilder(str);
	}
	
	public String toString() {
		return mStringBuilder.toString();
	}
	
	public void appendString(NSString str) {
		mStringBuilder.append(str);
	}
	
	public void deleteCharactersInRange(NSRange range) {
		int location = range.location;
		mStringBuilder.delete(location, location + range.length);
	}
	
	public void setString(NSString str) {
		mStringBuilder.delete(0, mStringBuilder.length());
		if (str != null) { 
			mStringBuilder.append(str);
		}
	}
	
	public void insertStringAtIndex(NSString str, int index) {
		mStringBuilder.insert(index, str);
	}
	
}
